package com.hdsx.restful.glzt.roadline.ldmclx.rest;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.springframework.stereotype.Service;

import com.hdsx.restful.glzt.roadline.ldmclx.bean.Ldmclx;
import com.hdsx.restful.glzt.roadline.ldmclx.service.LdmclxService;
import com.hdsx.restful.util.CheckEmpty;
import com.hdsx.restful.util.EasyUI;

@Path("/mclx")
@Service
public class LdmclxRestServer {
	@Resource(name="ldmclxServiceImpl")
	private LdmclxService service;
	/**
	 * Gets the list.
	 * 
	 * @param
	 * @param
	 * @return the list
	 */
	@GET
	@Path("/list")
	@Produces(MediaType.APPLICATION_JSON)
	public EasyUI<Ldmclx> queryList(@QueryParam("lxdm") String lxdm,@QueryParam("page") int page,@QueryParam("rows") int rows) {
		EasyUI<Ldmclx> uiPage = new EasyUI<Ldmclx>(page, rows);
		int count =service.queryCountByParameter(lxdm);
		List<Ldmclx> servicefws= service.queryByParameter(lxdm,uiPage.getBegin(),uiPage.getEnd());
		uiPage.setTotal(count);
		uiPage.setRows(servicefws);
		return uiPage;
	}
	
	@GET
	@Path("/queryLdmclxString")
	@Produces(MediaType.APPLICATION_JSON)
	public String queryLdmclxString(@QueryParam("id") String id)
	{
		return service.queryLdmclxString(id);
	}
	
	@GET
	@Path("/detail")
	@Produces(MediaType.APPLICATION_JSON)
	public EasyUI<Ldmclx> detail(@QueryParam("xzqhbm") String xzqhbm,@QueryParam("mclx")int mclx,@QueryParam("page") int page,@QueryParam("rows") int rows){
		xzqhbm = CheckEmpty.subXzqhbm(xzqhbm);
		EasyUI<Ldmclx> easyUI=new EasyUI<Ldmclx>(page,rows);
		Map<String,Object> map = easyUI.getParameter();
		map.put("xzqhbm", xzqhbm);
		map.put("mclx", mclx);
		List<Ldmclx> lists=service.queryDetail(map);
		int total = service.countDetail(map);
		easyUI.setRows(lists);
		easyUI.setTotal(total);
		return easyUI;
	}

}
